﻿<UserControl 
	x:Class="ICSharpCode.PackageManagement.RegisteredPackageSourcesUserControl"
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
	xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
	xmlns:pm="clr-namespace:ICSharpCode.PackageManagement"
	xmlns:pmd="clr-namespace:ICSharpCode.PackageManagement.Design"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	mc:Ignorable="d"
	d:DesignHeight="300"
	d:DesignWidth="300">
	
	<Grid d:DataContext="{d:DesignInstance pmd:DesignTimeRegisteredPackageSourcesViewModel, IsDesignTimeCreatable=True}">
		<Grid.Resources>
			<Style
				x:Key="ListBoxItemStyle"
				TargetType="{x:Type ListBoxItem}">
				
				<Style.Resources>
					<SolidColorBrush
						x:Key="{x:Static SystemColors.ControlBrushKey}"
						Color="{DynamicResource {x:Static SystemColors.HighlightColorKey}}" />
				</Style.Resources>
				
				<Setter
					Property="Background"
					Value="LightGray"/>
				
				<Style.Triggers>
					<Trigger
						Property="ItemsControl.AlternationIndex"
						Value="0">
						<Setter
							Property="Background"
							Value="White"/>
					</Trigger>
				</Style.Triggers>
			</Style>
			
			<DataTemplate x:Key="PackageSourceListBoxTemplate">
				<StackPanel
					x:Name="PackageSourceStackPanel"
					Margin="4">
					<CheckBox
						Content="{Binding Path=Name}"
						IsChecked="{Binding Path=IsEnabled}"/>
					<TextBlock>
						<Hyperlink>
							<TextBlock Text="{Binding Path=SourceUrl}"/>
						</Hyperlink>
					</TextBlock>
				</StackPanel>
			</DataTemplate>
		</Grid.Resources>
		
		<Grid.ColumnDefinitions>
			<ColumnDefinition />
			<ColumnDefinition Width="Auto"/>
		</Grid.ColumnDefinitions>
		<Grid.RowDefinitions>
			<RowDefinition />
			<RowDefinition Height="Auto"/>
		</Grid.RowDefinitions>
		<ListBox
			Grid.Row="0"
			HorizontalContentAlignment="Stretch"
			AlternationCount="2"
			pm:ListBoxBehaviour.IsSelectedItemScrolledIntoView="True"
			ItemContainerStyle="{StaticResource ListBoxItemStyle}"
			ItemTemplate="{StaticResource PackageSourceListBoxTemplate}"
			ItemsSource="{Binding Path=PackageSourceViewModels}"
			SelectedItem="{Binding Path=SelectedPackageSourceViewModel}"/>
		<Grid
			Grid.Row="1"
			Margin="4">
			<Grid.ColumnDefinitions>
				<ColumnDefinition Width="Auto"/>
				<ColumnDefinition />
			</Grid.ColumnDefinitions>
			<Grid.RowDefinitions>
				<RowDefinition />
				<RowDefinition />
			</Grid.RowDefinitions>
			<TextBlock
				Grid.Row="0"
				Grid.Column="0"
				Margin="4"
				Text="Name:"/>
			<TextBox
				Grid.Row="0"
				Grid.Column="1"
				Text="{Binding Path=NewPackageSourceName, UpdateSourceTrigger=PropertyChanged}"
				Margin="4, 2"/>
			<TextBlock
				Grid.Row="1"
				Grid.Column="0"
				Margin="4"
				Text="Source:"/>
			<TextBox
				Grid.Row="1"
				Grid.Column="1"
				Text="{Binding Path=NewPackageSourceUrl, UpdateSourceTrigger=PropertyChanged}"
				Margin="4,2"/>
		</Grid>
		<StackPanel
			Grid.Column="1"
			Grid.Row="0">
			<Button
				Content="Move Up"
				Command="{Binding Path=MovePackageSourceUpCommand}"
				Margin="4, 2"
				Padding="7, 0"/>
			<Button
				Content="Move Down"
				Command="{Binding Path=MovePackageSourceDownCommand}"
				Margin="4, 2"
				Padding="7, 0"/>
			<Button
				Content="Remove"
				Command="{Binding Path=RemovePackageSourceCommand}"
				Margin="4, 2"
				Padding="7, 0"/>
		</StackPanel>
		<StackPanel
			Grid.Column="1"
			Grid.Row="1">
			<Button
				Content="Add"
				Command="{Binding Path=AddPackageSourceCommand}"
				Margin="4, 6, 4, 4"
				Padding="7, 0"/>
			<Button
				Content="..."
				Command="{Binding Path=BrowsePackageFolderCommand}"
				HorizontalAlignment="Left"
				Margin="4, 4"
				Padding="7, 0"/>
		</StackPanel>
	</Grid>
</UserControl>